package com.comtop.db.fastar

import java.sql.DriverManager
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.rdd.JdbcRDD
import java.util.Properties
import java.io.FileInputStream

object JdbcConnection {
   val conf = new SparkConf().setAppName("FastarData")
                              .setMaster("local[1]")
                              .set("spark.driver.allowMultipleContexts", "true")
   val sc = new SparkContext(conf)
  
   var filePath = ""
   
   /**
   * 创建数据库连接
   */
   def getConnection() = {
       Class.forName("com.comtop.fastar.jdbc.FastarDriver").newInstance()
       DriverManager.getConnection("jdbc:fastar:10.10.61.21:10071", "root", "888888")
    }
  
  
   def getFilePath() = {
     var properties = new Properties
     val path = Thread.currentThread().getContextClassLoader.getResource("config.properties").getPath 
      properties.load(new FileInputStream(path))
      filePath = properties.getProperty("filePath")
      println("[获取到文件路径]： " + filePath)
   }
   
  
   
  def main(args: Array[String]): Unit = {
    
  }
  
}